import { APP_ROUTE_NAME } from "@/utils/data/constant";
import { createRouter, createWebHistory } from "vue-router";
const router = createRouter({
    routes: [
        {
            path: '/',
            name: APP_ROUTE_NAME,
            redirect: '/home',
            component: () => import('@/views/main.vue'),
            meta: {
                auth: true
            },
            children: [
                {
                    path: '/:pathMatch(.*)',
                    component: () => import('@/views/permission/notfound/index.vue'),
                    meta: {},
                    beforeEnter: (to) => {
                        const toRoute = router.getRoutes()
                            .find((item) => to.path.toLowerCase() == item.path.toLowerCase());
                        if (toRoute) {
                            return to;
                        }
                    }
                },
                {
                    path: '/permission',
                    children: [
                        {
                            path: '/permission/notpermission',
                            name: 'notpermission',
                            component: () => import('@/views/permission/notpermission/index.vue')
                        },
                        {
                            path: '/permission/notfound',
                            name: 'notfound',
                            component: () => import('@/views/permission/notfound/index.vue')
                        }
                    ]
                }
            ]
        },
        {
            path: '/login',
            name: 'login',
            component: () => import('@/views/login/index.vue')
        }
    ],
    history: createWebHistory()
});
export default router;